///-------------------功能说明--------------///
///1.构造方块类型
///2.插入方块类型到数组
///3.方块类型旋转
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace TetrisGame
{
    public struct VectorToInt 
    {
        public int x;
        public int y;
        public VectorToInt(int x,int y)
        {
            this.x = x;
            this.y = y;
        }
        public void SetValue(int x, int y)
        {
            this.x = x;
            this.y = y;
        }
        public void MoveValueX(int x)
        {
                this.x += x;
           
        }
        public void SetValueY(int y)
        {
            this.y = y;
        }
    }
    public enum TetrisTypeEnum {A,B,C,D,E,F,G }


    public class TetrisMoveArray 
    {
        //int wide;
        //int high;
        //int[,] tetrisArray;
        int[,] Type0 = new int[,] { { 1, 1 }, { 1, 1 } };
        int[,] Type1 = new int[,] { { 0, 1,0 }, { 1, 1,1 } };
        int[,] Type2 = new int[,] { { 1, 1, 0 }, { 0, 1, 1 } };
        int[,] Type3 = new int[,] { { 1, 1, 1,1 } };
        int[,] Type4 = new int[,] { { 1, 1, 1,  },{ 0,0,1} };
        int[,] Type5 = new int[,] { { 0, 0, 1, }, { 1, 1, 1 } };
        int[,] Type6 = new int[,] { { 0, 1, 1 }, { 1, 1, 0 } };
        Dictionary<TetrisTypeEnum, int[,]> tetrisTypeDis;
        //public int[,] TetrisArray { get => tetrisArray;}

        /// <summary>
        /// 构造数组和类型字典
        /// </summary>
        /// <param name="wide"></param>
        /// <param name="high"></param>
        public TetrisMoveArray()
        {
            //this.wide = wide;
            //this.high = high;
            //tetrisArray = new int[wide, high];
            tetrisTypeDis = new Dictionary<TetrisTypeEnum, int[,]>(7);
            tetrisTypeDis.Add(TetrisTypeEnum.A, Type0);
            tetrisTypeDis.Add(TetrisTypeEnum.B, Type1);
            tetrisTypeDis.Add(TetrisTypeEnum.C, Type2);
            tetrisTypeDis.Add(TetrisTypeEnum.D, Type3);
            tetrisTypeDis.Add(TetrisTypeEnum.E, Type4);
            tetrisTypeDis.Add(TetrisTypeEnum.F, Type5);
            tetrisTypeDis.Add(TetrisTypeEnum.G, Type6);
        }
     

        /// <summary>
        /// 插入类型到数组
        /// </summary>
        /// <param name="type"></param>
        /// <param name="vector"></param>
        //public  void AddTypeArray(TetrisTypeEnum type, VectorToInt vector)
        //{
        //    Initialized();
        //    int[,] tetris = tetrisTypeDis[type];
        //    for (int i = 0; i < tetris.GetLength(0); i++)
        //    {
        //        for (int j = 0; j < tetris.GetLength(1); j++)
        //        {
        //            if (i + vector.x< wide&& j + vector.y<high)
        //            {
        //                tetrisArray[i + vector.x, j + vector.y] = tetris[i, j];
        //            }
                   
        //        }
        //    }
        //}
        public int[,] GetTypeArray(TetrisTypeEnum type)
        {
            return tetrisTypeDis[type];
        }
      //  /// <summary>
      //  // 重置数组
      //// / </summary>
      //  public void Initialized()
      //  {
      //      for (int i = 0; i < wide; i++)
      //      {
      //          for (int j = 0; j < high; j++)
      //          {
      //              tetrisArray[i, j] = 0;
      //          }
      //      }
      //  }
    }
  
}
